package E2020;

import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class TCPServerSocket {
    public static void main(String[] args) {
        ServerSocket server = null;
        try {
            server = new ServerSocket(7777);
            while (true){
                System.out.println("服务器端等待接收连接中....");
                Socket client = server.accept();
                System.out.println("成功连接！！！开始数据交互~");

                OutputStream os = client.getOutputStream();
                os.write("服务器向客户端做出了响应！！！".getBytes());

                Thread.sleep(100);
                os.close();
                client.close();
            }
        } catch (Exception e){
            e.printStackTrace();
        }
    }
}
